home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / CMApplication.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  11.3 KB  |  406 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CMApplication.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __CMAPPLICATION__
  18. #define __CMAPPLICATION__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __QUICKDRAW__
  27. #include <Quickdraw.h>
  28. #endif
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <QuickdrawText.h>                                    */
  31.  
  32. #ifndef __WINDOWS__
  33. #include <Windows.h>
  34. #endif
  35. /*    #include <Memory.h>                                            */
  36. /*    #include <Events.h>                                            */
  37. /*        #include <OSUtils.h>                                    */
  38. /*    #include <Controls.h>                                        */
  39. /*        #include <Menus.h>                                        */
  40.  
  41. #ifndef __PRINTING__
  42. #include <Printing.h>
  43. #endif
  44. /*    #include <Errors.h>                                            */
  45. /*    #include <Dialogs.h>                                        */
  46. /*        #include <TextEdit.h>                                    */
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52. #if GENERATINGPOWERPC
  53. #pragma options align=mac68k
  54. #endif
  55.  
  56. #ifdef __CFM68K__
  57. #pragma lib_export on
  58. #endif
  59.  
  60.  
  61. enum {
  62.     gestaltColorMatchingVersion    = 'cmtc'
  63. };
  64.  
  65. enum {
  66.     gestaltColorSync10            = 0x0100,                        /* 0x0100 & 0x0110 _Gestalt versions for 1.0-1.0.3 product */
  67.     gestaltColorSync11            = 0x0110,                        /*   0x0100 == low-level matching only */
  68.     gestaltColorSync104            = 0x0104,                        /* Real version, by popular demand */
  69.     gestaltColorSync105            = 0x0105
  70. };
  71.  
  72. enum {
  73.     gestaltColorMatchingAttr    = 'cmta'
  74. };
  75.  
  76. /* Attribute bit numbers for gestaltColorMatchingAttr */
  77. enum {
  78.     gestaltHighLevelMatching    = 0,
  79.     gestaltColorMatchingLibLoaded = 1
  80. };
  81.  
  82. /* 68K A-trap */
  83. enum {
  84.     CMTrap                        = 0xABEE
  85. };
  86.  
  87. /* PicComments */
  88. enum {
  89.     CMBeginProfile                = 220,
  90.     CMEndProfile                = 221,
  91.     CMEnableMatching            = 222,
  92.     CMDisableMatching            = 223
  93. };
  94.  
  95. /* Defines for fieldMask in profile search record */
  96. enum {
  97.     kMatchCMMType                = 0x00000001,
  98.     kMatchApplProfileVersion    = 0x00000002,
  99.     kMatchDataType                = 0x00000004,
  100.     kMatchDeviceType            = 0x00000008,
  101.     kMatchDeviceManufacturer    = 0x00000010,
  102.     kMatchDeviceModel            = 0x00000020,
  103.     kMatchDeviceAttributes        = 0x00000040,
  104.     kMatchFlags                    = 0x00000080,
  105.     kMatchOptions                = 0x00000100,
  106.     kMatchWhite                    = 0x00000200,
  107.     kMatchBlack                    = 0x00000400
  108. };
  109.  
  110. /* Profile Header version */
  111. enum {
  112.     kCMApplProfileVersion        = 0x0100
  113. };
  114.  
  115. /* Data types */
  116. enum {
  117.     rgbData                        = 'RGB ',
  118.     cmykData                    = 'CMYK',
  119.     grayData                    = 'GRAY',
  120.     xyzData                        = 'XYZ '
  121. };
  122.  
  123. /* Device types */
  124. enum {
  125.     monitorDevice                = 'mntr',
  126.     scannerDevice                = 'scnr',
  127.     printerDevice                = 'prtr',
  128.     qdSystemDevice                = 'sys ',
  129.     qdGDevice                    = 'gdev'
  130. };
  131.  
  132. /* Profile flags */
  133. enum {
  134.     CMNativeMatchingPreferred    = 0x00000001,                    /* Default to native not preferred */
  135.     CMTurnOffCache                = 0x00000002                    /* Default to turn on CMM cache */
  136. };
  137.  
  138. typedef long CMMatchFlag;
  139.  
  140. /* Profile options */
  141.  
  142. enum {
  143.     CMPerceptualMatch            = 0x0000,                        /* Default. For photographic images */
  144.     CMColorimetricMatch            = 0x0001,                        /* Exact matching when possible */
  145.     CMSaturationMatch            = 0x0002                        /* For solid colors */
  146. };
  147.  
  148. typedef long CMMatchOption;
  149.  
  150. typedef long CMMatchRef;
  151.  
  152. typedef long CWorld;
  153.  
  154. /* ColorSync result codes */
  155.  
  156. enum {
  157.     CMNoError                    = 0,
  158.     CMProfileError                = -170,
  159.     CMMethodError                = -171,
  160.     CMMemFullError                = -172,
  161.     CMUnimplementedError        = -173,
  162.     CMParamError                = -174,
  163.     CMMethodNotFound            = -175,                            /* CMM not present */
  164.     CMProfileNotFound            = -176,                            /* Responder error */
  165.     CMProfilesIdentical            = -177,                            /* Profiles the same */
  166.     CMCantConcatenateError        = -178,                            /* Profile can't be concatenated */
  167.     CMCantXYZ                    = -179,                            /* CMM cant handle XYZ space */
  168.     CMCantDeleteProfile            = -180,                            /* Responder error */
  169.     CMUnsupportedDataType        = -181,                            /* Responder error */
  170.     CMNoCurrentProfile            = -182                            /* Responder error */
  171. };
  172.  
  173. typedef long CMError;
  174.  
  175. /*
  176. ** Types
  177. */
  178. struct XYZColor {
  179.     unsigned short                    X;                            /* 1.15 bit unsigned fixed numbers */
  180.     unsigned short                    Y;
  181.     unsigned short                    Z;
  182. };
  183. typedef struct XYZColor XYZColor;
  184.  
  185. struct CMYKColor {
  186.     unsigned short                    cyan;
  187.     unsigned short                    magenta;
  188.     unsigned short                    yellow;
  189.     unsigned short                    black;
  190. };
  191. typedef struct CMYKColor CMYKColor;
  192.  
  193. union CMColor {
  194.     RGBColor                        rgb;
  195.     XYZColor                        xyz;
  196.     CMYKColor                        cmyk;
  197. };
  198. typedef union CMColor CMColor, *CMColorList;
  199.  
  200. typedef long *CMGamutResult;
  201.  
  202. struct CMHeader {
  203.     unsigned long                    size;                        /* This is the total size of the Profile including custom data */
  204.     OSType                            CMMType;                    /* Corresponding CMM */
  205.     unsigned long                    applProfileVersion;            /* Version of CMProfile format */
  206.     OSType                            dataType;                    /* rgbData, etc. */
  207.     OSType                            deviceType;                    /* monitorDevice, etc. */
  208.     OSType                            deviceManufacturer;            /* Registered with DTS */
  209.     unsigned long                    deviceModel;                /* Specific to Manufacturer */
  210.     unsigned long                    deviceAttributes[2];        /* Attributes like paper, ink, etc. */
  211.     unsigned long                    profileNameOffset;            /* Offset to profile name from top of data */
  212.     unsigned long                    customDataOffset;            /* Offset to custom data from top of data */
  213.     CMMatchFlag                        flags;
  214.     CMMatchOption                    options;
  215.     XYZColor                        white;
  216.     XYZColor                        black;
  217. };
  218. typedef struct CMHeader CMHeader;
  219.  
  220. struct CMProfileSearchRecord {
  221.     CMHeader                        header;
  222.     unsigned long                    fieldMask;
  223.     unsigned long                    reserved[2];
  224. };
  225. typedef struct CMProfileSearchRecord CMProfileSearchRecord, **CMProfileSearchRecordHandle;
  226.  
  227. struct CMProfileChromaticities {
  228.     XYZColor                        red;
  229.     XYZColor                        green;
  230.     XYZColor                        blue;
  231.     XYZColor                        cyan;
  232.     XYZColor                        magenta;
  233.     XYZColor                        yellow;
  234. };
  235. typedef struct CMProfileChromaticities CMProfileChromaticities;
  236.  
  237. typedef unsigned short CMResponseData;
  238.  
  239. struct IString {
  240.     ScriptCode                        theScript;
  241.     Str63                            theString;
  242. };
  243. typedef struct IString IString, *IStringPtr, **IStringHandle;
  244.  
  245.  
  246. enum {
  247.     grayResponse                = 0,
  248.     redResponse                    = 1,
  249.     greenResponse                = 2,
  250.     blueResponse                = 3,
  251.     cyanResponse                = 4,
  252.     magentaResponse                = 5,
  253.     yellowResponse                = 6,
  254.     ucrResponse                    = 7,
  255.     bgResponse                    = 8,
  256.     onePlusLastResponse            = 9
  257. };
  258.  
  259. typedef long responseColor;
  260.  
  261. struct CMProfileResponse {
  262.     unsigned short                    counts[onePlusLastResponse];
  263.     CMResponseData                    data[1];                    /* Variable size */
  264. };
  265. typedef struct CMProfileResponse CMProfileResponse;
  266.  
  267. struct CMProfile {
  268.     CMHeader                        header;
  269.     CMProfileChromaticities            profile;
  270.     CMProfileResponse                response;                    /* Variable size */
  271.     IString                            profileName;                /* Variable size */
  272.     char                            customData[1];                /* Optional variable length custom CMM data */
  273. };
  274. typedef struct CMProfile CMProfile, *CMProfilePtr, **CMProfileHandle;
  275.  
  276. typedef pascal Boolean (*PixMapCallBackProcPtr)(long progress, long refCon);
  277.  
  278. #if GENERATINGCFM
  279. typedef UniversalProcPtr PixMapCallBackUPP;
  280. #else
  281. typedef PixMapCallBackProcPtr PixMapCallBackUPP;
  282. #endif
  283.  
  284. enum {
  285.     uppPixMapCallBackProcInfo = kPascalStackBased
  286.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  287.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  288.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  289. };
  290.  
  291. #if GENERATINGCFM
  292. #define NewPixMapCallBackProc(userRoutine)        \
  293.         (PixMapCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppPixMapCallBackProcInfo, GetCurrentArchitecture())
  294. #else
  295. #define NewPixMapCallBackProc(userRoutine)        \
  296.         ((PixMapCallBackUPP) (userRoutine))
  297. #endif
  298.  
  299. #if GENERATINGCFM
  300. #define CallPixMapCallBackProc(userRoutine, progress, refCon)        \
  301.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppPixMapCallBackProcInfo, (progress), (refCon))
  302. #else
  303. #define CallPixMapCallBackProc(userRoutine, progress, refCon)        \
  304.         (*(userRoutine))((progress), (refCon))
  305. #endif
  306.  
  307. /*
  308. ** Printing Stuff that will be moved later
  309. */
  310.  
  311. enum {
  312.     enableColorMatchingOp        = 12,
  313.     registerProfileOp            = 13
  314. };
  315.  
  316. /* PrGeneral parameter blocks */
  317. struct TEnableColorMatchingBlk {
  318.     short                            iOpCode;
  319.     short                            iError;
  320.     long                            lReserved;
  321.     THPrint                            hPrint;
  322.     Boolean                            fEnableIt;
  323.     SInt8                            filler;
  324. };
  325. typedef struct TEnableColorMatchingBlk TEnableColorMatchingBlk;
  326.  
  327. struct TRegisterProfileBlk {
  328.     short                            iOpCode;
  329.     short                            iError;
  330.     long                            lReserved;
  331.     THPrint                            hPrint;
  332.     Boolean                            fRegisterIt;
  333.     SInt8                            filler;
  334. };
  335. typedef struct TRegisterProfileBlk TRegisterProfileBlk;
  336.  
  337. /*
  338. ** High Level Calls
  339. */
  340. extern pascal CMError BeginMatching(CMProfileHandle src, CMProfileHandle dst, CMMatchRef *myRef)
  341.  FOURWORDINLINE(0x203c, 0x000C, 10, 0xABEE);
  342. extern pascal void EndMatching(CMMatchRef myRef)
  343.  FOURWORDINLINE(0x203c, 0x0004, 11, 0xABEE);
  344. extern pascal CMError GetProfile(long deviceType, long refNum, CMProfileHandle aProfile, CMProfileHandle *returnedProfile)
  345.  FOURWORDINLINE(0x203c, 0x0010, 5, 0xABEE);
  346. extern pascal CMError SetProfile(long deviceType, long refNum, CMProfileHandle newProfile)
  347.  FOURWORDINLINE(0x203c, 0x000c, 6, 0xABEE);
  348. extern pascal CMError SetProfileDescription(long deviceType, long refNum, long deviceData, CMProfileHandle hProfile)
  349.  FOURWORDINLINE(0x203c, 0x0010, 16, 0xABEE);
  350. extern pascal CMError GetColorSyncFolderSpec(short vRefNum, Boolean createFolder, short *foundVRefNum, long *foundDirID)
  351.  FOURWORDINLINE(0x203c, 0x000c, 17, 0xABEE);
  352. extern pascal CMError GetIndexedProfile(long deviceType, long refNum, CMProfileSearchRecordHandle search, CMProfileHandle *returnProfile, long *index)
  353.  FOURWORDINLINE(0x203c, 0x0014, 18, 0xABEE);
  354. extern pascal CMError DeleteDeviceProfile(long deviceType, long refNum, CMProfileHandle deleteMe)
  355.  FOURWORDINLINE(0x203c, 0x000C, 19, 0xABEE);
  356. /*
  357. ** Data interchange routines
  358. */
  359. extern pascal CMError UseProfile(CMProfileHandle profile)
  360.  FOURWORDINLINE(0x203c, 0x0004, 8, 0xABEE);
  361. extern pascal void DrawMatchedPicture(PicHandle myPicture, CMProfileHandle dst, Rect *myRect)
  362.  FOURWORDINLINE(0x203c, 0x000C, 9, 0xABEE);
  363. extern pascal void EnableMatching(Boolean enableIt)
  364.  FOURWORDINLINE(0x203c, 0x0002, 13, 0xABEE);
  365. /*
  366. ** Profile concatenation
  367. */
  368. extern pascal CMError ConcatenateProfiles(CMProfileHandle thru, CMProfileHandle dst, CMProfileHandle *newDst)
  369.  FOURWORDINLINE(0x203c, 0x000C, 12, 0xABEE);
  370. /*
  371. ** Profile manipulation routines
  372. */
  373. extern pascal void GetProfileName(CMProfileHandle myProfile, IString *IStringResult)
  374.  FOURWORDINLINE(0x203c, 0x0008, 14, 0xABEE);
  375. extern pascal long GetProfileAdditionalDataOffset(CMProfileHandle myProfile)
  376.  FOURWORDINLINE(0x203c, 0x0004, 15, 0xABEE);
  377. /*
  378. ** Low level color calculation routines
  379. */
  380. extern pascal CMError CWNewColorWorld(CWorld *myCWorld, CMProfileHandle src, CMProfileHandle dst)
  381.  FOURWORDINLINE(0x203c, 0x000C, 0, 0xABEE);
  382. extern pascal void CWDisposeColorWorld(CWorld myCWorld)
  383.  FOURWORDINLINE(0x203c, 0x0004, 1, 0xABEE);
  384. extern pascal CMError CWMatchColors(CWorld myCWorld, CMColorList myColors, long count)
  385.  FOURWORDINLINE(0x203c, 0x000c, 2, 0xABEE);
  386. extern pascal CMError CWCheckColors(CWorld myCWorld, CMColorList myColors, long count, CMGamutResult result)
  387.  FOURWORDINLINE(0x203c, 0x0010, 3, 0xABEE);
  388. extern pascal CMError CWMatchPixMap(CWorld myCWorld, PixMap *myPixMap, PixMapCallBackUPP progressProc, long refCon)
  389.  FOURWORDINLINE(0x203c, 0x0010, 4, 0xABEE);
  390. extern pascal CMError CWCheckPixMap(CWorld myCWorld, PixMap *myPixMap, PixMapCallBackUPP progressProc, long refCon, BitMap *resultBitMap)
  391.  FOURWORDINLINE(0x203c, 0x0014, 7, 0xABEE);
  392.  
  393. #ifdef __CFM68K__
  394. #pragma lib_export off
  395. #endif
  396.  
  397. #if GENERATINGPOWERPC
  398. #pragma options align=reset
  399. #endif
  400.  
  401. #ifdef __cplusplus
  402. }
  403. #endif
  404.  
  405. #endif /* __CMAPPLICATION__ */
  406.